//
//  BHNavigationController.m
//  xinlangweibo0621
//
//  Created by boldseas on 2017/6/21.
//  Copyright © 2017年 renbohan. All rights reserved.
//

//随机色
#define BHRandomColor BHColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))

//RGB颜色
#define BHColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]



#import "BHNavigationController.h"
#import "UIBarButtonItem+Extension.h"

@interface BHNavigationController ()

@end

@implementation BHNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:20];
    
    [self.navigationBar setTitleTextAttributes:attrs];
}

+ (void)initialize{
    
    
    UIBarButtonItem *item = [UIBarButtonItem appearance];
    
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    attrs[NSForegroundColorAttributeName] = BHColor(252, 129, 36);
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    
    NSMutableDictionary *disableAttrs = [NSMutableDictionary dictionary];
    disableAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    disableAttrs[NSForegroundColorAttributeName] = [UIColor redColor];
    [item setTitleTextAttributes:disableAttrs forState:UIControlStateDisabled];
    
    
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
        

        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"navigationbar_back" highImage:@"navigationbar_back_highlighted" target:self action:@selector(back)];
        

        viewController.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImage:@"navigationbar_more" highImage:@"navigationbar_more_highlighted" target:self action:@selector(more)];
    }
    [super pushViewController:viewController animated:YES];
}

- (void)back{
    [self popViewControllerAnimated:YES];
}

- (void)more{
    [self popToRootViewControllerAnimated:YES];
}

@end
